@use "sass:list";

.vxe-password-input--wrapper {
  flex-grow: 1;
  overflow: hidden;
}
.vxe-password-input--inner {
  display: block;
  width: 100%;
  height: 100%;
  outline: 0;
  margin: 0;
  font-size: inherit;
  font-family: inherit;
  line-height: inherit;
  padding: 0 0.5em;
  color: var(--vxe-ui-font-color);
  border: 0;
  border-radius: var(--vxe-ui-base-border-radius);
  background-color: var(--vxe-ui-layout-background-color);
  box-shadow: none;
  &::placeholder {
    color: var(--vxe-ui-input-placeholder-color);
  }
  &::-webkit-autofill {
    background-color: var(--vxe-ui-layout-background-color);
  }
  &[type="number"] {
    appearance: none;
    -moz-appearance: textfield;
  }
  &[type="search"],
  &[type="search"]::-webkit-search-cancel-button,
  &[type="number"]::-webkit-outer-spin-button,
  &[type="number"]::-webkit-inner-spin-button {
    appearance: none;
  }
  &[disabled] {
    cursor: not-allowed;
    color: var(--vxe-ui-font-disabled-color);
    background-color: var(--vxe-ui-input-disabled-background-color);
  }
}

// 禁用
.vxe-password-input {
  &.is--disabled {
    background-color: var(--vxe-ui-input-disabled-background-color);
    .vxe-password-input--prefix,
    .vxe-password-input--suffix,
    .vxe-password-input--clear-icon,
    .vxe-password-input--control-icon {
      cursor: not-allowed;
    }
    .vxe-password-input--prefix,
    .vxe-password-input--suffix {
      background-color: var(--vxe-ui-input-disabled-background-color);
    }
  }
}

// 图标
.vxe-password-input {
  display: inline-flex;
  flex-direction: row;
  position: relative;
  border-radius: var(--vxe-ui-base-border-radius);
  width: 180px;
  border: 1px solid var(--vxe-ui-input-border-color);
  &.is--active {
    border: 1px solid var(--vxe-ui-font-primary-color);
  }
  &.show--clear {
    &:hover {
      .vxe-password-input--clear-icon {
        display: block;
      }
    }
  }
}
.vxe-password-input--prefix,
.vxe-password-input--suffix {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-shrink: 0;
  background-color: var(--vxe-ui-layout-background-color);
}
.vxe-password-input--prefix-icon {
  padding-left: 0.5em;
}
.vxe-password-input--clear-icon,
.vxe-password-input--control-icon,
.vxe-password-input--suffix-icon {
  padding-right: 0.5em;
}
.vxe-password-input--clear-icon,
.vxe-password-input--control-icon {
  height: 100%;
  color: var(--vxe-ui-input-placeholder-color);
  cursor: pointer;
}
.vxe-password-input--clear-icon {
  display: none;
  &:hover {
    color: var(--vxe-ui-font-color);
  }
  &:active {
    color: var(--vxe-ui-font-primary-color);
  }
}

.vxe-password-input--number-btn {
  height: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  &:hover {
    color: var(--vxe-ui-font-color);
  }
  &:active {
    color: var(--vxe-ui-font-primary-color);
  }
}
.vxe-password-input--number-icon {
  display: flex;
  flex-direction: column;
  height: 100%;
  .vxe-password-input--number-btn {
    &.is--disabled {
      cursor: no-drop;
      color: var(--vxe-ui-font-disabled-color);
    }
  }
}

// 统计字数
.vxe-password-input--count {
  flex-shrink: 0;
  color: var(--vxe-ui-input-count-color);
  background-color: var(--vxe-ui-layout-background-color);
  padding-right: 0.6em;
  &.is--error {
    color: var(--vxe-ui-input-count-error-color);
  }
}

// 对齐方式
.vxe-password-input {
  &.is--left {
    .vxe-password-input--inner {
      text-align: left;
    }
  }
  &.is--center {
    .vxe-password-input--inner {
      text-align: center;
    }
  }
  &.is--right {
    .vxe-password-input--inner {
      text-align: right;
    }
  }
}

.vxe-password-input--panel {
  display: none;
  position: absolute;
  left: 0;
  padding: 4px 0;
  color: var(--vxe-ui-font-color);
  font-size: var(--vxe-ui-font-size-default);
  text-align: left;
  &:not(.is--transfer) {
    min-width: 100%;
  }
  &.is--transfer {
    position: fixed;
  }
  &.ani--leave {
    display: block;
    opacity: 0;
    transform: scaleY(0.5);
    transition: transform .3s cubic-bezier(.23,1,.32,1), opacity .3s cubic-bezier(.23,1,.32,1);
    transform-origin: center top;
    backface-visibility: hidden;
    transform-style: preserve-3d;
    &[placement="top"] {
      transform-origin: center bottom;
    }
  }
  &.ani--enter {
    opacity: 1;
    transform: scaleY(1);
  }
}

.vxe-password-input {
  font-size: var(--vxe-ui-font-size-default);
  height: var(--vxe-ui-input-height-default);
  line-height: var(--vxe-ui-input-height-default);
  .vxe-password-input--inner {
    &[type="date"]::-webkit-inner-spin-button,
    &[type="month"]::-webkit-inner-spin-button,
    &[type="week"]::-webkit-inner-spin-button {
      margin-top: 6px;
    }
    &[type="date"]::-webkit-inner-spin-button,
    &[type="month"]::-webkit-inner-spin-button,
    &[type="week"]::-webkit-inner-spin-button,
    &[type="number"]::-webkit-inner-spin-button {
      height: 24px;
    }
  }
  &.size--medium {
    font-size: var(--vxe-ui-font-size-medium);
    height: var(--vxe-ui-input-height-medium);
    line-height: var(--vxe-ui-input-height-medium);
    .vxe-password-input--inner {
      &[type="date"]::-webkit-inner-spin-button,
      &[type="month"]::-webkit-inner-spin-button,
      &[type="week"]::-webkit-inner-spin-button {
        margin-top: 4px;
      }
    }
  }
  &.size--small {
    font-size: var(--vxe-ui-font-size-small);
    height: var(--vxe-ui-input-height-small);
    line-height: var(--vxe-ui-input-height-small);
    .vxe-password-input--inner {
      &[type="date"]::-webkit-inner-spin-button,
      &[type="month"]::-webkit-inner-spin-button,
      &[type="week"]::-webkit-inner-spin-button {
        margin-top: 2px;
      }
    }
  }
  &.size--mini {
    font-size: var(--vxe-ui-font-size-mini);
    height: var(--vxe-ui-input-height-mini);
    line-height: var(--vxe-ui-input-height-mini);
    .vxe-password-input--inner {
      &[type="date"]::-webkit-inner-spin-button,
      &[type="month"]::-webkit-inner-spin-button,
      &[type="week"]::-webkit-inner-spin-button {
        margin-top: 0;
      }
    }
  }
}

@mixin getPanelStyle ($sizeIndex) {
  $fontSizeList: var(--vxe-ui-font-size-default), var(--vxe-ui-font-size-medium), var(--vxe-ui-font-size-small), var(--vxe-ui-font-size-mini);
  $timeWeekRowHeightList: var(--vxe-ui-input-date-time-week-row-height-default), var(--vxe-ui-input-date-time-week-row-height-medium), var(--vxe-ui-input-date-time-week-row-height-small), var(--vxe-ui-input-date-time-week-row-height-mini);
  $monthYearRowHeightList: var(--vxe-ui-input-date-month-year-row-height-default), var(--vxe-ui-input-date-month-year-row-height-medium), var(--vxe-ui-input-date-month-year-row-height-small), var(--vxe-ui-input-date-month-year-row-height-mini);
  $quarterRowHeightList: var(--vxe-ui-input-date-quarter-row-height-default), var(--vxe-ui-input-date-quarter-row-height-medium), var(--vxe-ui-input-date-quarter-row-height-small), var(--vxe-ui-input-date-quarter-row-height-mini);
  $titleRowHeightList: var(--vxe-ui-input-date-title-height-default), var(--vxe-ui-input-date-title-height-medium), var(--vxe-ui-input-date-title-height-small), var(--vxe-ui-input-date-title-height-mini);
  
  font-size: list.nth($fontSizeList, $sizeIndex);
  .vxe-password-input--panel-wrapper {
    max-height: 400px - $sizeIndex * 20;
  }
  &.type--date,
  &.type--time,
  &.type--week,
  &.type--month,
  &.type--quarter,
  &.type--year {
    .vxe-password-input--panel-wrapper {
      padding: 12px - $sizeIndex;
    }
  }
  &.type--date,
  &.type--month,
  &.type--quarter,
  &.type--year {
    .vxe-password-input--panel-wrapper {
      $widthList: 336px, 336px, 312px, 288px;
      width: list.nth($widthList, $sizeIndex);
    }
  }
  &.type--week {
    .vxe-password-input--panel-wrapper {
      $widthList: 380px, 380px, 354px, 326px;
      width: list.nth($widthList, $sizeIndex);
    }
  }
  &.type--time {
    .vxe-password-input--panel-wrapper {
      $widthList: 170px, 168px, 154px, 146px;
      width: list.nth($widthList, $sizeIndex);
    }
  }
  &.type--datetime {
    .vxe-password-input--panel-left-wrapper {
      $widthList: 336px, 336px, 312px, 288px;
      width: list.nth($widthList, $sizeIndex);
    }
    .vxe-password-input--panel-left-wrapper,
    .vxe-password-input--panel-right-wrapper {
      padding: 12px - $sizeIndex;
    }
  }
  .vxe-password-input--time-picker-title {
    height: 31px - $sizeIndex;
    line-height: 31px - $sizeIndex;
    padding: 0 12px - $sizeIndex;
  }
  .vxe-password-input--date-picker-label,
  .vxe-password-input--date-picker-btn {
    height: 31px - $sizeIndex;
    line-height: 31px - $sizeIndex;
  }
  .vxe-password-input--date-picker-btn-wrapper {
    .vxe-password-input--date-picker-btn {
      margin-left: 9px - $sizeIndex;
    }
    .vxe-password-input--date-picker-prev-btn,
    .vxe-password-input--date-picker-current-btn,
    .vxe-password-input--date-picker-next-btn {
      width: 31px - $sizeIndex;
      border-radius: var(--vxe-ui-base-border-radius);
      border: 1px solid var(--vxe-ui-input-border-color);
    }
  }
  .vxe-password-input--date-picker-type-wrapper {
    .vxe-password-input--date-picker-label,
    .vxe-password-input--date-picker-btn {
      padding: 0 10px - $sizeIndex;
    }
  }
  .vxe-password-input--time-picker-header,
  .vxe-password-input--date-picker-header {
    $paddingBottomList: 8px, 7px, 6px, 5px;
    padding-bottom: list.nth($paddingBottomList, $sizeIndex);
  }
  .vxe-password-input--date-picker-body table,
  .vxe-password-input--time-picker-body {
    height: calc(list.nth($timeWeekRowHeightList, $sizeIndex) * 6 + list.nth($titleRowHeightList, $sizeIndex));
  }
  .vxe-password-input--time-picker-body {
    $ulWidthList: 48px, 48px, 44px, 42px;
    & > ul {
      width: list.nth($ulWidthList, $sizeIndex);
      &:before,
      &:after {
        $heightList: 120px, 120px, 110px, 100px;
        height: list.nth($heightList, $sizeIndex);
      }
      & > li {
        height: 26px;
        padding-left: 10px - $sizeIndex;
      }
    }
    .vxe-password-input--time-picker-minute-list {
      left: list.nth($ulWidthList, $sizeIndex);
    }
    .vxe-password-input--time-picker-second-list {
      left: calc(list.nth($ulWidthList, $sizeIndex) * 2);
    }
  }
  .vxe-password-input--date-day-view,
  .vxe-password-input--date-week-view {
    td {
      height: list.nth($timeWeekRowHeightList, $sizeIndex);
    }
  }
  .vxe-password-input--date-quarter-view {
    td {
      height: list.nth($quarterRowHeightList, $sizeIndex);
    }
  }
  .vxe-password-input--date-month-view,
  .vxe-password-input--date-year-view {
    td {
      height: list.nth($monthYearRowHeightList, $sizeIndex);
    }
  }
  .vxe-password-input--date-picker-body {
    th {
      height: list.nth($titleRowHeightList, $sizeIndex);
    }
  }
  .vxe-password-input--time-picker-confirm,
  .vxe-password-input--date-picker-confirm {
    height: 31px - $sizeIndex;
    padding: 0 10px - $sizeIndex;
  }
  .vxe-password-input--date-label {
    line-height: calc(list.nth($fontSizeList, $sizeIndex) + 1px);
  }
}

.vxe-password-input--panel {
  @include getPanelStyle(1);
  &.size--medium {
    @include getPanelStyle(2);
  }
  &.size--small {
    @include getPanelStyle(3);
  }
  &.size--mini {
    @include getPanelStyle(4);
  }
}
